<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pyPong.gesture &mdash; pyPong v0.1d0 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.1d0',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyPong v0.1d0 documentation" href="../index.html" />
    <link rel="next" title="pyPong.game" href="game.html" />
    <link rel="prev" title="pyPong.video" href="video.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="game.html" title="pyPong.game"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="video.html" title="pyPong.video"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyPong v0.1d0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-gesture">
<h1><cite>pyPong.gesture</cite><a class="headerlink" href="#module-gesture" title="Permalink to this headline">¶</a></h1>
<p>gesture.py
a component of pyPong.py</p>
<p>Derive a signal from a processed webcam image</p>
<p>Copyright (c) 2010 John Graves
MIT License: see LICENSE.txt</p>
<dl class="class">
<dt id="gesture.Gesture">
<em class="property">class </em><tt class="descclassname">gesture.</tt><tt class="descname">Gesture</tt><a class="headerlink" href="#gesture.Gesture" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the highest significant selected point on each side of the image.</p>
<p>A webcam image processed with the green screen approach (background subtraction)
may have white pixels which can be used to extract a signal from a gesture (hand movement).</p>
<p>This implementation looks along rows of pixels, counting the non-black (white) pixels.
Any count over 5 (about finger width) is considered a valid selection.</p>
<p>Due to the imperfect filtering of the green screen approach (artifacts),
the scan looks down a few additional rows to see if they are also selected
(since a finger tip is usually connected to a hand below ...).</p>
<dl class="method">
<dt id="gesture.Gesture.countWhitePixels">
<tt class="descname">countWhitePixels</tt><big>(</big><em>image</em><big>)</big><a class="headerlink" href="#gesture.Gesture.countWhitePixels" title="Permalink to this definition">¶</a></dt>
<dd>Steps down from top row of image within 40 pixels from left and right sides.  Checks every other row for over 5 white pixels.
Sets signal when it finds three selected rows together.</dd></dl>

<dl class="method">
<dt id="gesture.Gesture.isWhite">
<tt class="descname">isWhite</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#gesture.Gesture.isWhite" title="Permalink to this definition">¶</a></dt>
<dd>Actually just tests x &gt; 0.  Used in sum(map( function , row of pixels )) with True counting as 1 to count non-black pixels.</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="video.html"
                                  title="previous chapter"><cite>pyPong.video</cite></a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="game.html"
                                  title="next chapter"><cite>pyPong.game</cite></a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/modules/gesture.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="game.html" title="pyPong.game"
             >next</a> |</li>
        <li class="right" >
          <a href="video.html" title="pyPong.video"
             >previous</a> |</li>
        <li><a href="../index.html">pyPong v0.1d0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, John Graves.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
    </div>
  </body>
</html>